//
//  ChangeWalletListCell.m
//  ShandsMod
//
//  Created by zh s on 2023/3/20.
//  Copyright © 2023 zh_s. All rights reserved.
//

#import "ChangeWalletListCell.h"

@interface ChangeWalletListCell ()

/**! backImage*/
@property (nonatomic, strong) UIImageView *backImage;
@property (nonatomic, strong) UIImageView *stateImg;

@end

@implementation ChangeWalletListCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.accessoryType = UITableViewCellAccessoryNone;
        self.backgroundColor = [UIColor clearColor];
        [self createView];
    }
    return self;
}

- (void)createView {
    UIView *backV = [[UIView alloc] init];
    [self.contentView addSubview:backV];
//    backV.backgroundColor = UIColor.redColor;
    backV.frame = CGRectMake(20, 0, SCREEN_WIDTH - 40, 100);

    
    UIImageView *backImage = [[UIImageView alloc] init];
    backImage.image = IMAGE_NAME(@"bg_walletList_nol");
    backImage.contentMode = UIViewContentModeScaleAspectFill;
    backImage.clipsToBounds = YES;
    backImage.userInteractionEnabled = YES;
    [backV addSubview:backImage];
//    backImage.frame = CGRectMake(5, 0, SCREEN_WIDTH - 5, 40);
    [backImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(5);
        make.left.mas_equalTo(-10);
        make.right.mas_equalTo(backV.mas_right).mas_offset(-45);
        make.height.mas_equalTo(87);
    }];
    _backImage = backImage;
    
    UILabel *titleLab = [[UILabel alloc] init];
    [backV addSubview:titleLab];
    titleLab.textColor = UIColor.whiteColor;
    titleLab.font = FONT_NAME(@"DINCond-Bold", 25);
    titleLab.text = @"BSC-1";
    [titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.top.mas_equalTo(12);
        make.height.mas_equalTo(47);
    }];
    
    UILabel *walletLab = [[UILabel alloc] init];
    [backV addSubview:walletLab];
    walletLab.textColor = RGBA(255, 255, 255, 0.5);
    walletLab.font = FONT_NAME(FONT_Regular, 10);
    walletLab.text = @"钱包名称";
    [walletLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(titleLab.mas_left);
        make.top.mas_equalTo(54);
        make.height.mas_equalTo(20);
    }];
    
    
    UIImageView *stateImg = [[UIImageView alloc] init];
    [backV addSubview:stateImg];
    stateImg.image = IMAGE_NAME(@"icon_walletList_nol");
    stateImg.userInteractionEnabled = YES;
    [stateImg addTapGestureTarget:self action:@selector(chooseWallet)];
    [stateImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(backV.mas_right).mas_offset(-5);
        make.width.height.mas_equalTo(20);
        make.centerY.mas_equalTo(backImage.mas_centerY);
    }];
    _stateImg = stateImg;

}

- (void)setValueWithModel:(NSInteger)model {
    if (model == 1) {
        _backImage.image = IMAGE_NAME(@"bg_home_wallet_other");
    }else if (model == 2) {
        _backImage.image = IMAGE_NAME(@"bg_walletList_nol");
    }else {
        _backImage.image = IMAGE_NAME(@"bg_home_wallet_other");
    }
}

- (void)chooseWallet {
    _stateImg.image = IMAGE_NAME(@"icon_walletList_sel");
}

@end
